<template>
  <el-tabs type="border-card">
    <el-tab-pane label="平台分类数据">
      <spider-type-data :platforms="platforms"/>
    </el-tab-pane>
    <el-tab-pane label="全平台数据">
      <spider-type-e-charts :platforms="platforms"/>
    </el-tab-pane>
    <!--<el-tab-pane label="补抓数据功能" v-if="$store.state.user.level.id <=2">
      <iresearch_data_collection :platforms="platforms"/>
    </el-tab-pane>-->
  </el-tabs>
</template>

<script>

  import Project_search_category from '../component/project_search_category';
  import Iresearch_data_collection from '../component/iresearch_data_collection';
  import SpiderTypeData from '../component/spiderTypeData';
  import SpiderTypeECharts from '../component/spiderTypeECharts';

  export default {
    components: {
      SpiderTypeECharts,
      SpiderTypeData,
      Iresearch_data_collection,
      Project_search_category,
    },
    data() {
      return {
        loading: true,
        isSameDay: false,
        filter: {date: null, selected: null},
        platforms: {},
        history: [],
        table: {date: [], data: []},
        tableDataIndex: [
          {title: '活跃主播数量', index: 'active'},
          {title: '观看人数', index: 'watch'},
          {title: '主播开播数量', index: 'open'},
          {title: '主播新增数量', index: '_new'},
          {title: '礼物价值趋势', index: 'gift'},
        ],
        dateOption: {
          shortcuts: [
            {
              text: '最近一周',
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit('pick', [start, end]);
              },
            }, {
              text: '最近一个月',
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                picker.$emit('pick', [start, end]);
              },
            }, {
              text: '最近三个月',
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                picker.$emit('pick', [start, end]);
              },
            }],
        },
      };
    },
    methods: {
      async getPlatforms() {
        const res = await this.$asyncHttp.get('/api/spider/platforms');
        this.platforms = res.data;
      },
    },
    mounted() {
      this.getPlatforms();
    },
  };
</script>

<style scoped>
</style>